<!DOCTYPE html>
<html class="ie9 no-focus" lang="en"> <![endif]-->
<html class="no-focus" lang="en">
<head>
    <meta charset="utf-8">

    <title> &amp; </title>

    <meta name="description" content="OneUI - Admin Dashboard Template &amp; UI Framework created by pixelcave and published on Themeforest">
    <meta name="author" content="pixelcave">
    <meta name="robots" content="noindex, nofollow">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=0">


    <link rel="shortcut icon" href="assets/img/favicons/favicon.png">
    <link rel="icon" type="image/png" href="assets/img/favicons/favicon-16x16.png" sizes="16x16">
    <link rel="icon" type="image/png" href="assets/img/favicons/favicon-32x32.png" sizes="32x32">
    <link rel="icon" type="image/png" href="assets/img/favicons/favicon-96x96.png" sizes="96x96">
    <link rel="icon" type="image/png" href="assets/img/favicons/favicon-160x160.png" sizes="160x160">
    <link rel="icon" type="image/png" href="assets/img/favicons/favicon-192x192.png" sizes="192x192">
    <link rel="apple-touch-icon" sizes="57x57" href="assets/img/favicons/apple-touch-icon-57x57.png">
    <link rel="apple-touch-icon" sizes="60x60" href="assets/img/favicons/apple-touch-icon-60x60.png">
    <link rel="apple-touch-icon" sizes="72x72" href="assets/img/favicons/apple-touch-icon-72x72.png">
    <link rel="apple-touch-icon" sizes="76x76" href="assets/img/favicons/apple-touch-icon-76x76.png">
    <link rel="apple-touch-icon" sizes="114x114" href="assets/img/favicons/apple-touch-icon-114x114.png">
    <link rel="apple-touch-icon" sizes="120x120" href="assets/img/favicons/apple-touch-icon-120x120.png">
    <link rel="apple-touch-icon" sizes="144x144" href="assets/img/favicons/apple-touch-icon-144x144.png">
    <link rel="apple-touch-icon" sizes="152x152" href="assets/img/favicons/apple-touch-icon-152x152.png">
    <link rel="apple-touch-icon" sizes="180x180" href="assets/img/favicons/apple-touch-icon-180x180.png">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400italic,600,700%7COpen+Sans:300,400,400italic,600,700">
    <link rel="stylesheet" href="assets/js/plugins/datatables/jquery.dataTables.min.css">
    <link rel="stylesheet" href="assets/css/bootstrap.min.css">
    <link rel="stylesheet" id="css-main" href="assets/css/oneui.css">
</head>
<body>
<div id="page-container" class="sidebar-l sidebar-o side-scroll header-navbar-fixed">

     <!-- Sidebar -->
            <nav id="sidebar">
                <!-- Sidebar Scroll Container -->
                <div id="sidebar-scroll">
                    <!-- Sidebar Content -->
                    <!-- Adding .sidebar-mini-hide to an element will hide it when the sidebar is in mini mode -->
                    <div class="sidebar-content">
                        <!-- Side Header -->
                        <div class="side-header side-content bg-white-op">
                            <!-- Layout API, functionality initialized in App() -> uiLayoutApi() -->
                            <button class="btn btn-link text-gray pull-right hidden-md hidden-lg" type="button" data-toggle="layout" data-action="sidebar_close">
                                <i class="fa fa-times"></i>
                            </button>                       
                            <a class="h5 text-white" href="main.html">
                                <i class="fa fa-circle-o-notch text-primary"></i> <span class="h4 font-w600 sidebar-mini-hide">me</span>
                            </a>
                        </div>
                        <!-- END Side Header -->

                        <!-- Side Content -->
                         <div class="side-content side-content-full">
                            <ul class="nav-main">                                
                                <li class="nav-main-heading"><span class="sidebar-mini-hide">目录</span></li>
                                <li>
                                    <a class="" href="main.html"><i class="si si-cup"></i><span class="sidebar-mini-hide">首页</span></a>
                                </li>
                                <li>
                                    <a class="" href="allstudy.html"><i class="si si-book-open"></i><span class="sidebar-mini-hide">学习资源</span></a>
                                </li>
                                <li>
                                    <a class="" href="mystudy.html"><i class="si si-book-open"></i><span class="sidebar-mini-hide">我的学习</span></a>
                                </li>
                                <li class="open">
                                    <a class="nav-submenu" data-toggle="nav-submenu" href="#"><i class="si si-grid"></i><span class="sidebar-mini-hide">管理</span></a>
                                    <ul>
                                        <li>
                                            <a class="" href="videomanage.html">视频资源</a>
                                        </li>
                                        <li>
                                            <a class="active" href="docmanage.html">文档资源</a>
                                        </li>
                                        <li>
                                            <a class="" href="learnermanage.html">学习者管理</a>
                                        </li>
                                        <li>
                                            <a class="" href="newsource.html">资源上传</a>
                                        </li>
                                        <li>
                                            <a class="" href="audit.html">资源审核</a>
                                        </li>
                                    </ul>
                                </li>
                                <li class="open">
                                    <a class="nav-submenu" data-toggle="nav-submenu" href="#"><i class="si si-user"></i><span class="sidebar-mini-hide">个人中心</span></a>
                                    <ul>
                                        <li>
                                            <a class="" href="myself.html">个人信息</a>
                                        </li>
                                        <li>
                                            <a class="" href="mypassword.html">修改密码</a>
                                        </li>
                                    </ul>
                                </li>
                            </ul>
                        </div>
                        <!-- END Side Content -->
                    </div>
                    <!-- Sidebar Content -->
                </div>
                <!-- END Sidebar Scroll Container -->
            </nav>
            <!-- END Sidebar -->
            
             <!-- Header -->
            <header id="header-navbar" class="content-mini content-mini-full">                            
                <!-- Header Navigation Left -->
                <ul class="nav-header pull-left">
                    <li class="hidden-md hidden-lg">
                        <!-- Layout API, functionality initialized in App() -> uiLayoutApi() -->
                        <button class="btn btn-default" data-toggle="layout" data-action="sidebar_toggle" type="button">
                            <i class="fa fa-navicon"></i>
                        </button>
                    </li>
                    <li class="hidden-xs hidden-sm">
                        <!-- Layout API, functionality initialized in App() -> uiLayoutApi() -->
                        <button class="btn btn-default" data-toggle="layout" data-action="sidebar_mini_toggle" type="button">
                            <i class="fa fa-ellipsis-v"></i>
                        </button>
                    </li>                                                          
                </ul>
            </header>


    <!-- Main Container -->
    <main id="main-container">

        <!-- Page Content -->
        <div class="content">
            <!-- Dynamic Table Full Pagination -->
            <div class="block">
                <div class="block-header">
                    <h3 class="block-title">文档</h3>
                </div>
                <div class="block-content" id="document">
                    <!-- DataTables init on table by adding .js-dataTable-full-pagination class, functionality initialized in js/pages/base_tables_datatables.js -->
                    <table class="table table-bordered table-striped js-dataTable-full">
                        <thead>
                        <tr>
                            <th class="hidden-xs text-center" style="width: 10%;">序号</th>
                            <th class="hidden-xs text-center">文档名称</th>
                            <th class="hidden-xs text-center">所属课程</th>
                            <th class="hidden-xs text-center" style="width: 15%;">难度</th>
                            <th class="text-center" style="width: 10%;">打开文档</th>
                            <th class="text-center" style="width: 10%;">编辑栏</th>
                        </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
            <!-- END Dynamic Table Full Pagination -->
        </div>
        <!-- END Page Content -->
    </main>
    <!-- END Main Container -->

    <script src="assets/js/core/jquery.min.js"></script>
    <script src="assets/js/core/bootstrap.min.js"></script>
    <script src="assets/js/core/jquery.slimscroll.min.js"></script>
    <script src="assets/js/core/jquery.scrollLock.min.js"></script>
    <script src="assets/js/core/jquery.appear.min.js"></script>
    <script src="assets/js/core/jquery.countTo.min.js"></script>
    <script src="assets/js/core/jquery.placeholder.min.js"></script>
    <script src="assets/js/core/js.cookie.min.js"></script>
    <script src="assets/js/app.js"></script>
    <script src="js/contextPath.js"></script>
    <script>
        $(document).ready(function () {
            $.ajax({
                url: contextPath + "all/doc",
                contentType: "application/json; charset=utf-8",
                type: "GET",
                dataType: "json",
                success: function (data) {
                    var list = data.list;
                    var mydatables = $(".js-dataTable-full").DataTable({
                        pageLength: 10,
                        lengthMenu: [[5, 10, 15, 20], [5, 10, 15, 20]],
                        data: list,
                        createdRow:function (row) {
                            $('td', row).attr("class", "text-center");
                        },
                        columns: [
                            {data: null},
                            {data: 'doc_name'},
                            {data: 'coursedir'},
                            {data: 'difficulty'},
                            {data: null},
                            {data: null}
                        ],
                        columnDefs: [{
                            orderable: false,
                            targets: 0
                        },{
                            orderable: false,
                            targets: 4,
                            render:function (data) {
                                return '<button href="javascript:void(0)" class="btn btn-xs btn-default" type="button" data-toggle="modal" name="'+data.url+'" title="打开"><i class="si-doc"></i></button>';
                            }
                        }, {
                            orderable: false,
                            targets: 5,
                            render:function (data) {
                                return '<div class="btn-group"><button class="btn btn-xs btn-default" type="button" data-toggle="tooltip" name="'+data.id+'" title="编辑"><i class="fa fa-pencil"></i></button>' +
                                    '<button href="javascript:void(0)" type="button" data-toggle="tooltip" name="'+data.id+'" title="删除"><i class="fa fa-times"></i></button></div>';
                            }
                        }
                        ],
                        oLanguage: {
                            "sZeroRecords": "抱歉， 没有找到",
                            "sInfoEmpty": "没有数据",
                            "sInfoFiltered": "(从 _MAX_ 条数据中检索)"
                        }
                    });
                    mydatables.on('order.dt search.dt', function () {
                        mydatables.column(0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
                            cell.innerHTML = i+1;
                        } );
                    }).draw();
                }
            });
        });
        $("table").on("click", "button", function() {
            var title = $(this).attr("title");
            var id;
            if(title === "打开"){

            }else if(title === "编辑"){

            }else if(title === "删除"){
                id = $(this).attr("name");
                layer.alert('确定删除该文档?',{
                    skin: 'layui-layer-molv' //样式类名  自定义样式
                    ,closeBtn: 1    // 是否显示关闭按钮
                    ,anim: 1 //动画类型
                    ,btn: ['确定','取消'] //按钮
                    ,icon: 6    // icon
                },function(){
                    $.ajax({
                        url: contextPath+"document/"+id,
                        contentType : "application/json; charset=utf-8",
                        type: "DELETE",
                        dataType: "json",
                        success: function(data) {

                        }
                    });
                });
            }
        });
    </script>

    <!-- Page JS Plugins -->
    <script src="assets/js/plugins/datatables/jquery.dataTables.min.js"></script>

    <!-- Page JS Code -->
    <script src="assets/js/pages/base_tables_datatables.js"></script>
</div>
</body>
</html>